package dao;

import hbt.HbtUtil;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import bean.FacturaVO;

public class HbtFacturaDao {

	private static SessionFactory sf = null;
	private static HbtFacturaDao instancia = null;

	public static HbtFacturaDao getInstancia() {
		if (instancia == null) {
			sf = HbtUtil.getSessionFactory();
			instancia = new HbtFacturaDao();
		}
		return instancia;
	}

	public void guardarFactura(FacturaVO factura) {
		Session session = sf.openSession();
		session.beginTransaction();
		session.persist(factura);
		session.flush();
		session.getTransaction().commit();
		session.close();
	}

	public FacturaVO obtenerFactura(FacturaVO f) {
		Session session = sf.openSession();
		FacturaVO factura = (FacturaVO) session.get(FacturaVO.class,
				f.getNroFactura());
		session.close();
		return factura;
	}

}
